package com.cloudfun.campusshare.repo;

import com.cloudfun.campusshare.common.constant.PromotionStatus;
import com.cloudfun.campusshare.common.constant.PromotionType;
import com.cloudfun.campusshare.entity.PromotionEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;

/**
 * Created by CodeGenerator on 2020/06/06
 */
public interface PromotionRepo extends PagingAndSortingRepository<PromotionEntity, String>, JpaSpecificationExecutor<PromotionEntity> {

    Long countAllByCreateTimeGreaterThanEqual(String createTimeStart);

    List<PromotionEntity> findAllByIdIn(List<String> ids);

    List<PromotionEntity> findAllByStatusInOrderByCreateTime(Collection<PromotionStatus> status);

    List<PromotionEntity> findAllByTypeAndWashPointIdAndStartTimeGreaterThanEqualAndEndTimeLessThanEqual(PromotionType promotionType, String washPointId,LocalDateTime startTime, LocalDateTime endTime);
}